package com.xjw.service.impl;

import java.util.List;

import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.xjw.dao.UserDao;
import com.xjw.entity.User;
import com.xjw.service.UserService;

/**      
 * 项目名称：springMvc  
 * 实现功能：  
 * 类名称：UserServiceImpl   
 * 类描述：(该类的主要功能)
 * 创建人：徐纪伟 
 * E-mail: xjw@jysdsoft.com
 * 创建时间：2013-3-22上午09:08:59   
 * 修改人：   
 * 修改时间：   
 * 版权 :京源时代
 * 修改备注：   
 * @version    
 */
@Service
public class UserServiceImpl implements UserService {

	@Resource(name="userDaoImpl")
	private UserDao userDao;
	
	public void create(User user) {
		userDao.create(user);

	}

	public void delete(User user) {
		userDao.delete(user);

	}

	public List<User> list() {
		// TODO Auto-generated method stub
		System.out.println(userDao.list());
		return userDao.list();
	}

	public void update(User user) {
		userDao.update(user);

	}

	public User get(String username) {
		// TODO Auto-generated method stub
		return userDao.get(username);
	}

	public int count() {
		// TODO Auto-generated method stub
		return userDao.count();
	}

	@Transactional(propagation=Propagation.REQUIRED, rollbackFor=Exception.class)
	public void inOrUp(User user) {
		userDao.create(user);
		user.setPassword("*************************************************************************************************************************************************************************");
		user.setPassword("*******");
		userDao.update(user);
		
	}

}
